<!-- 字典项管理 -->

<template>
    <KeepAlive :include="[]">
        <component :is="curComponent" :dictionaryInfo="dictionaryInfo" @updateDictionaryInfo="updateDictionaryInfo"/>
    </KeepAlive>
</template>

<script setup>
import { ref } from 'vue';

import DictionaryAdd from './c/DictionaryAdd.vue';
import DictionaryEdit from './c/DictionaryEdit.vue';
import DictionaryList from './c/DictionaryList.vue';
import DictionaryPreview from './c/DictionaryPreview.vue';

const type = ref('list');
const dictionaryInfo = ref({});

const componentMap = {
    'list': DictionaryList,
    'edit': DictionaryEdit,
    'add': DictionaryAdd,
    'preview': DictionaryPreview
};

const curComponent = ref(DictionaryList);

const updateDictionaryInfo = (val) => {
    type.value = val.type;
    dictionaryInfo.value = val.dictionaryInfo;
    
    curComponent.value = componentMap[type.value];
};

</script>

<style lang="scss">
@import url('./index.scss');
</style>